package org.wak.character
{
	import org.wak.character.display.AbstractCharacterDisplay;
	import org.wak.main.AdventureMaster;

	/**
	 * Encapsulates a Character Definition Data from an input XML. 
	 * 
	 */	
	public class XMLCharacterDefinition implements ICharacterDefinition
	{
		// Input XML with the Character Definition.
		private var mInputXML:XML ;
		
		// The current characterDisplay of the character
		private var mCharacterDisplay:String = "";
		
		// the character Id
		private var mCharacterId:String = "" ;
		
		// the character Name
		private var mInteractionName:String = "" ;
		
		// the id of the current scene where this character is.
		private var mSceneId:String = "" ;
		
		// array of inventory items.
		private var mInventoryItems:Array = null ;
		
		// character's descroption
		private var mDescription:String = "";
		
		// the character's speech color.
		private var mSpeechColor:uint = 0xFFFFFF ;
		
		
		
		/**
		 * Constructor 
		 * @param Input XML with Character Definition.
		 * 
		 */		
		public function XMLCharacterDefinition(pXML:XML)
		{
			mInputXML = pXML ;
			mCharacterId = pXML.@id ;
			
			mDescription = pXML.Description ;
			mCharacterDisplay = pXML.CharacterDisplay ;
			mInteractionName = pXML.Name ;
			
			mInventoryItems = new Array();
			for each( var item:XML in pXML.Inventory.InventoryItem )
			{
				mInventoryItems.push( item[0] );
			}
			
			//trace("XMLCharacterDefinition:"+ "0x"+pXML.SpeechColor)
			mSpeechColor = uint("0x"+pXML.SpeechColor);
			
		}
		
		public function toString():String
		{
			return mCharacterId + " " +mCharacterDisplay + " " + mSceneId ;
		}
		
		public function get characterId():String 
		{
			return mCharacterId ;
		}
		
		public function get inventory():Array
		{
			return mInventoryItems;
		}
			
		
		public function get currentSceneId():String
		{
			return mSceneId;
		}
				
		public function get characterDisplayId():String
		{
			return mCharacterDisplay;
		}
		
		public function get interactionName():String 
		{
			return mInteractionName ;
		}
		
		public function get description():String
		{
			return mDescription ;
		}
		
		public function get speechColor():uint 
		{
			return mSpeechColor ;
		}
		
		
		
	}
}